﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="~/Manage/Cms/ContentItem.aspx.cs"
    Inherits="Manage_Cms_ContentItem" %>

<html>
<head>
    <!--#include file="../js/html_head.inc"-->
    <link rel="stylesheet" type="text/css" href="../Themes/<%=ManageHelper.GetTheme()%>/style.css" />

    <script type="text/javascript" src="../JS/ckeditor/ckeditor.js"></script>

    <script type="text/javascript" src="../JS/tools.js"></script>

</head>
<body>

    <script type="text/javascript">
        $(document).ready(function(){
            $("#spanStarteTime").hide();
            $("#spanEndTime").hide();
               
            $("#StarteTime").bind("focus", function(){
              WdatePicker({isShowClear:false,readOnly:false})
              });
            
            $("#EndTime").bind("focus", function(){
              WdatePicker({isShowClear:false,readOnly:false})
              });
          
            $("#txtCreateTime").bind("focus", function(){
              WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false,readOnly:false})
              });
        });
            
	    function toggleTitleFormat()
	    {
	        $("#formatTitlt").toggle();
	    }
	    
	      function ChangePublishType()
        {
            switch($("#publishType").val())
            {
                case "0":
                    $("#spanStarteTime").hide();
                    $("#spanEndTime").hide();
                    break;
                case "1":
                    $("#spanStarteTime").show();
                    break;
                case "2":
                    $("#spanStarteTime").show();
                    $("#spanEndTime").show();
                    break;
            }
        }
        
        <%if(IsShowEditor){%>
	    function GetKeywords()
	    {
            SetKeyWords($("#Title").val());	    
	    }
	    <%}%>
	    
	    
	    <%if(IsShowEditor){%>
	    window.onload = function()
	    {
		   CKEDITOR.replace( 'txtContent',
            {
				filebrowserBrowseUrl : '/Manage/JS/ckeditor/ckfinder/ckfinder.html',
				filebrowserImageBrowseUrl : '/Manage/JS/ckeditor/ckfinder/ckfinder.html?Type=Images',
				filebrowserFlashBrowseUrl : '/Manage/JS/ckeditor/ckfinder/ckfinder.html?Type=Flash',
				filebrowserUploadUrl : '/Manage/JS/ckeditor/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files',
				filebrowserImageUploadUrl : '/Manage/JS/ckeditor/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images',
				filebrowserFlashUploadUrl : '/Manage/JS/ckeditor/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash'
            } 
            );
	    };
	   <%}%>
	   
	   
	    var editor=CKEDITOR.replace( 'txtContent' );
　　    editor.document.getBody().getText(); //取得纯文本
        
        
         //清除空格
       function Remove_blank_lines()
       {
            var body = "\n"+editor.document.getBody().getText();
            body = body.replace(/ |　/ig,"");
            body = body.replace(/\r\n/ig,"\n");
            body = body.replace(/\n\n/ig,"\n");
            body = body.replace(/\n\n/ig,"\n");
            body = body.replace(/\n\n/ig,"\n");
            body = body.replace(/\n\n/ig,"\n");
            body = body.replace(/\n/ig,"  \n");
            body = body.replace("\n\n","\n");
            body=body.replace(/\n/ig,"<br />");
            CKEDITOR.instances.txtContent.setData(body);
       }
       
       
        //添加空行
       function Add_a_blank_line()
       {
            var body = "\n"+editor.document.getBody().getText();
            body = body.replace(/ |　/ig,"");
            body = body.replace(/\r\n/ig,"\n");
            body = body.replace(/\n\n/ig,"\n");
            body = body.replace(/\n\n/ig,"\n");
            body = body.replace(/\n\n/ig,"\n");
            body = body.replace(/\n\n/ig,"\n");
            body = body.replace(/\n/ig,"\n\n");
            body = body.replace("\n\n","");
            body=body.replace(/\n/ig,"<br />");
            CKEDITOR.instances.txtContent.setData(body);
       }
       
	    
	   //自动排版
	   function Automatic_layout()
       {
            var body = "\n"+CKEDITOR.instances.txtContent.getData();
          
            body = body.replace(/^\s*|\s*$/g,"");
            
            body = body.replace(/<\/?p\s*[^>]*>/ig,"");
            body = body.replace(/ |　/ig,"");
            body = body.replace(/\n/ig,"　　");
            body = body.replace("\n\n","");
           
            CKEDITOR.instances.txtContent.setData(body);

       }
       
       //清除JS
       function Clear_JS()
       {
            var value =  CKEDITOR.instances.txtContent.getData();
		    value = value.replace(/&lt;script[^>]*?&gt;(.|\n)*?&lt;\/script&gt;/ig,"");
		    value = value.replace(/&lt;marquee[^>]*?&gt;(.|\n)*?&lt;\/marquee&gt;/ig,"");
            CKEDITOR.instances.txtContent.setData(value);
       }
       
      
       
       //统计字数
       function Statistics_words()
       {
            var value = "\n"+editor.document.getBody().getText();
            value = value.replace(/^\s*|\s*$/g,"");
            value=value.replace(/\s|&nbsp;/g,"");
            var strlen;
            strlen= value.length;
            alert("目前长度" + strlen + "文字\n");
       }
       
       //清空内容
       function Empty()
       {
           CKEDITOR.instances.txtContent.setData("");
       }
    </script>

    <div class="column" style="margin: 0; padding: 0;">
        <div class="columntitle">
            添加内容
        </div>
        <form id="form1" action="?act=<%=act %>&contentid=<%=KeRui.Common.PageRequest.GetInt("contentid",-1) %>&siteid=<%=KeRui.Common.PageRequest.GetInt("siteid",-1) %>&nodeid=<%=KeRui.Common.PageRequest.GetInt("nodeid",-1) %>"
            onsubmit="return validator(this)" method="post">
            <table width="100%" cellpadding="3" cellspacing="3">
                <tr>
                    <td align="left" style="width: 80px">
                        <img name="help1" src="../pic/icons/help.gif" alt="选择包含此信息的栏目名称" onclick="helpInf(this)" />&nbsp;<span>栏目：</span>
                    </td>
                    <td colspan="3" align="left">
                        <select name="parentnodeid" id="ParentNodeID">
                           <%-- <%=SelectNodeList(0, KeRui.Common.PageRequest.GetInt("nodeid", -1) == -1 ? modelCmsContentShow.NodeID : KeRui.Common.PageRequest.GetInt("nodeid", -1))%>--%>
                            <%=SelectNodeList(0, KeRui.Common.PageRequest.GetInt("contentid", -1) != -1 ? modelCmsContentShow.NodeID : KeRui.Common.PageRequest.GetInt("nodeid", -1))%>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td align="left" style="width: 80px">
                        <img name="help1" src="../pic/icons/help.gif" alt="标题的名称" onclick="helpInf(this)" />&nbsp;<span>标题：</span>
                    </td>
                    <td colspan="3" align="left">
                        <input id="Title" name="txtTitle" style="height: 23px; width: 400px; background-image: url(../pic/titlerule.gif);
                            border: #7f9db9 1px solid;" type="text" value="<%=modelCmsContentShow.Title!=null ? modelCmsContentShow.Title.Replace("\"","“") :"" %>"
                            class="colorblur" onfocus="this.className='colorfocus';" onblur="this.className='colorblur';" />&nbsp;<span
                                id="Title_msg" style="color: red; display: none"></span>
                        <img src="../pic/Rect.gif" alt="color" name="MarkFontColor_Show" width="18" height="17"
                            border="0" align="middle" id="MarkFontColor_Show" style="cursor: pointer;" title="标题颜色选取"
                            onclick="GetColor(this,'TitleColor');" />
                        <span title="是否粗体">
                            <input id="TitleBTF" type="checkbox" name="TitleBTF" /></span><strong>B</strong>
                        <span title="是否斜体">
                            <input id="TitleITF" type="checkbox" name="TitleITF" /></span><i>I</i>
                        <iframe width="260" height="165" id="colorPalette" src="../JS/selcolor.htm" style="visibility: hidden;
                            position: absolute; border: 1px gray solid; left: 297px; top: -20px;" frameborder="0"
                            scrolling="no"></iframe>
                    </td>
                </tr>
                <tr id="RowCheckBoxList">
                    <td align="left" style="width: 80px">
                        <img name="help1" src="../pic/icons/help.gif" alt="设置此信息的显示属性" onclick="helpInf(this)" />
                        <span>显示属性：</span>
                    </td>
                    <td>
                        <input id="IsRecommend" type="checkbox" <%=modelCmsContentShow.IsRecommend?"checked=\"checked\" ":"" %>
                            name="IsRecommend" value="1" /><label for="IsRecommend">推荐</label>
                        <input id="IsHot" <%=modelCmsContentShow.IsHot?"checked=\"checked\" ":"" %> type="checkbox"
                            name="IsHot" value="1" /><label for="IsHot">热点</label>
                        <input id="IsColor" <%=modelCmsContentShow.IsMarked?"checked=\"checked\" ":"" %>
                            type="checkbox" name="IsColor" value="1" /><label for="IsColor">醒目</label>
                        <input id="IsTop" <%=modelCmsContentShow.IsTop?"checked=\"checked\" ":"" %> type="checkbox"
                            name="IsTop" value="1" /><label for="IsTop">置顶</label>
                    </td>
                </tr>
                <tr id="Tr3">
                    <td align="left" style="width: 80px">
                        <img name="help1" src="../pic/icons/help.gif" alt="设置文章属性" onclick="helpInf(this)" />
                        <span>新闻属性：</span>
                    </td>
                    <td>
                        <input id="Checkbox1" type="radio" <%=modelCmsContentShow.ContentType==0?"checked=\"checked\" ":"" %>
                            name="chkcontenttype" value="0" /><label for="Checkbox1">普通</label>
                        <input id="Checkbox2" <%=modelCmsContentShow.ContentType==1?"checked=\"checked\" ":"" %>
                            type="radio" name="chkcontenttype" value="1" /><label for="Checkbox2">图片</label>
                        <input id="Checkbox3" <%=modelCmsContentShow.ContentType==2?"checked=\"checked\" ":"" %>
                            type="radio" name="chkcontenttype" value="2" /><label for="Checkbox3">视频</label>
                        <input id="Checkbox4" <%=modelCmsContentShow.ContentType==3?"checked=\"checked\" ":"" %>
                            type="radio" name="chkcontenttype" value="3" /><label for="Checkbox4">外部链接</label>
                        <input id="Checkbox5" <%=modelCmsContentShow.ContentType==4?"checked=\"checked\" ":"" %>
                            type="radio" name="chkcontenttype" value="4" /><label for="Checkbox5">自定义</label>
                    </td>
                </tr>
                <%switch (act)
                  {
                      case "add":
                          Response.Write(FieldForm);
                          break;
                      case "modify":
                          Response.Write(strCmsContentDetails);
                          break;
                  }
                %>
                <tr id="trTemplateFile">
                    <td align="left" style="width: 80px">
                        <img name="help1" src="../pic/icons/help.gif" alt="模板文件" onclick="helpInf(this)" />
                        <span>模板文件：</span>
                    </td>
                    <td>
                        <select name="templatelist" id="templatelist">
                            <%=BuildTemplateList(modelCmsContentShow.TemplateFile) %>
                        </select>
                    </td>
                </tr>
                <tr id="trContentState">
                    <td align="left" style="width: 80px">
                        <img name="help1" src="../pic/icons/help.gif" alt="设置内容状态" onclick="helpInf(this)" />
                        <span>内容状态：</span>
                    </td>
                    <td>
                        <input type="radio" value="0" name="ContentState" <%=modelCmsContentShow.ContentState==0?"checked='checked'":"" %>
                            id="draft" /><label for="draft">草稿</label><input checked="checked" type="radio" value="1"
                                <%=modelCmsContentShow.ContentState==1?"checked='checked'":"" %> name="ContentState"
                                id="waitingforcheck" /><label for="waitingforcheck">待审核</label><input type="radio"
                                    value="2" <%=modelCmsContentShow.ContentState==2?"checked='checked'":"" %> name="ContentState"
                                    checked="checked" id="checkpassed" /><label for="checkpassed">审核通过</label>
                    </td>
                </tr>
                <tr id="trEnableComment">
                    <td align="left" style="width: 80px">
                        <img name="help1" src="../pic/icons/help.gif" alt="设置评论状态" onclick="helpInf(this)" />
                        <span>评论状态：</span>
                    </td>
                    <td>
                        <input type="radio" value="1" name="EnableComment" checked="checked" <%=modelCmsContentShow.EnableComment?"checked='checked'":"" %>
                            id="enablecomment" /><label for="enablecomment">允许评论</label><input type="radio" value="0"
                                name="EnableComment" <%=!modelCmsContentShow.EnableComment?"checked='checked'":"" %>
                                id="disablecomment" /><label for="disablecomment">不允许评论</label>
                    </td>
                </tr>
                <tr id="tr2">
                    <td align="left" style="width: 80px">
                        <img name="help1" src="../pic/icons/help.gif" alt="设置文章发表时间" onclick="helpInf(this)" />
                        <span>发表时间：</span>
                    </td>
                    <td>
                        <input name="txtCreateTime" id="txtCreateTime" value="<%=modelCmsContentShow.PublishTime.Year.ToString()=="1"?DateTime.Now:modelCmsContentShow.PublishTime%>"
                            type="text" class="Wdate" />
                    </td>
                </tr>
                <tr id="tr1">
                    <td align="left" style="width: 80px">
                        <img name="help1" src="../pic/icons/help.gif" alt="设置发布计划" onclick="helpInf(this)" />
                        <span>发布计划：</span>
                    </td>
                    <td>
                        <select name="publishType" id="publishType" onchange="ChangePublishType()">
                            <option value="9">立即发布</option>
                            <option value="0">手动统一发布</option>
                            <option value="1">自动发布</option>
                            <option value="2">自动发布并自动取消</option>
                        </select>
                        &nbsp;<span id="spanStarteTime">开始时间：<input name="StarteTime" id="StarteTime" type="text"
                            class="Wdate" /></span>&nbsp;<span id="spanEndTime">结束时间：<input name="EndTime" id="EndTime"
                                type="text" class="Wdate" /></span>
                    </td>
                </tr>
                <tr>
                    <td colspan="4" valign="middle">
                        <input type="submit" name="sub" value="<%if(act=="add"){Response.Write("添 加");}else{Response.Write("修 改");} %>"
                            id="Submit" class="button" />
                        &nbsp;&nbsp;
                        <input class="button" type="button" onclick="<%if (act == "add"){Response.Write("window.location.href='ContentList.aspx?siteid=" + KeRui.Common.PageRequest.GetInt("siteid", -1) + "&nodeid=" + KeRui.Common.PageRequest.GetInt("nodeid", -1) + "'"); }else { Response.Write("window.close();"); } %>"
                            value="返 回" />
                        <%--<input class="button" type="button" onclick="window.close()"
                            value="返 回" />--%>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    <script type="text/javascript">var editor=CKEDITOR.replace( 'txtContent' );</script>
</body>
</html>
